// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-7-7

#ifndef __COMBOBOX_H_COMMON_UI__
#define __COMBOBOX_H_COMMON_UI__

#pragma once

#include "listview.h"

class CJoyComboBox;

//##ModelId=44CF17B9009C
class CJoyComboItem : public CJoyListViewItem
{
protected:
	//##ModelId=44CF17B900AC
    virtual void CM_MouseLeave();
	//##ModelId=44CF17B900AE
    virtual void CM_MouseHover();
	//##ModelId=44CF17B900B0
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
	//##ModelId=44CF17B900BD
    virtual void CM_Draw(Graphics& graph);
public:
	//##ModelId=44CF17B900C0
    CJoyComboItem();
	//##ModelId=44CF17B900C1
    virtual ~CJoyComboItem();

	//##ModelId=44CF17B900CB
    CJoyComboBox* GetComboBox();
};

//##ModelId=44CF17B900CC
class CJoyComboList :
    public CJoyListView
{
	DECLARE_DYNAMIC(CJoyComboList)
protected:
    friend class CJoyComboBox;
    friend class CJoyComboItem;

	//##ModelId=44CF17B900DC
    CJoyComboBox*   m_comboBox;

	//##ModelId=44CF17B900E3
    static CJoyComboList* m_hookList;
	//##ModelId=44CF17B900EA
    static HHOOK    m_mouseHook;
	//##ModelId=44CF17B900EB
    static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);


public:
	//##ModelId=44CF17B900FC
    CJoyComboList(void);
	//##ModelId=44CF17B900FE
    virtual ~CJoyComboList(void);

	//##ModelId=44CF17B90101
    CJoyComboBox* GetComboBox()
    {
        return m_comboBox;
    }

public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44CF17B90109
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	//##ModelId=44CF17B9010D
    afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	//##ModelId=44CF17B90119
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	//##ModelId=44CF17B9011D
    afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
	//##ModelId=44CF17B90128
    afx_msg void OnSize(UINT nType, int cx, int cy);
	//##ModelId=44CF17B9012D
    afx_msg void OnClose();
};

//##ModelId=44CF17B90138
class CJoyComboBox :
    public CJoyWnd
{
	DECLARE_DYNAMIC(CJoyComboBox)
protected:
	//##ModelId=44CF17B90149
    int             m_selMargin;
	//##ModelId=44CF17B9014A
    int             m_expMargin;
	//##ModelId=44CF17B9014B
    int             m_listMargin;
	//##ModelId=44CF17B9014C
    int             m_listHeight;
	//##ModelId=44CF17B90158
    CJoyButton*     m_btnExpand;
	//##ModelId=44CF17B9015D
    CJoyComboItem*  m_selItem;
	//##ModelId=44CF17B90162
    CJoyComboList*  m_comboList;

	//##ModelId=44CF17B90167
    void BuidlCtrlArea();

	//##ModelId=44CF17B90168
    virtual CJoyComboList* CreateList();

	//##ModelId=44CF17B9016A
    virtual void CM_SelItem(CJoyComboItem* item);

	//##ModelId=44CF17B9016D
    virtual void CM_Expand(CJoyButton*);
	//##ModelId=44CF17B90179
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);
public:
	//##ModelId=44CF17B9017C
    CJoyComboBox(void);
	//##ModelId=44CF17B9017E
    virtual ~CJoyComboBox(void);

	//##ModelId=44CF17B90186
    CJoyComboList* GetComboList()
    {
        return m_comboList;
    }

	//##ModelId=44CF17B90187
    void SelItem(CJoyComboItem* item);
	//##ModelId=44CF17B90189
    CJoyComboItem* SelItem(int i);
	//##ModelId=44CF17B9018B
    int GetItemIndex(CJoyComboItem* item);
public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44CF17B9018D
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//##ModelId=44CF17B90198
    afx_msg void OnSize(UINT nType, int cx, int cy);
	//##ModelId=44CF17B9019D
    afx_msg void OnDestroy();
};


#endif  // __COMBOBOX_H_COMMON_UI__
